#ifndef __SCENE_MANAGER_HPP__
#define __SCENE_MANAGER_HPP__

#include "Entities/BaseEntity.hpp"

#include <vector>
#include <map>
#include <time.h>

using namespace std;


class SceneManager
{
public:
	static SceneManager* GetInstance();
	
	// Update and render entities.
	void                 UpdateScene( clock_t tick );

	// Registering entity in SceneManager.
	void                 RegisterEntity( BaseEntity* newEntity );

	// Unregister entity specified by entityID.
	// It should be destroyed on next UpdateScene invocation.
	void                 UnregisterEntity( int entityID );

	// Unregister all entities.
	void                 UnregisterAllEntities();

	// Call rendering method for all registered entities.
	// TODO: cull invisible entities.
	void                 drawEntities();

private:
	SceneManager();

	int                      GenerateUniqueID() { return ++m_idIndex; };

	static SceneManager*     m_instance;
	vector<int>              m_entitiesToDestroy;
	map<int, BaseEntity* >   m_entitiesMap;
	int                      m_idIndex;
	clock_t                  m_startTick;
	clock_t                  m_lastFrameTick;
	long                     m_numOfFrames;
};

#endif